package function;

import java.util.function.Function;

/**
 * @Auther Jun jie Yi
 * @Date 16:00 2021/6/27
 */
public class Function2Test {
    public static void main(String[] args) {

        Function<Integer, Integer> name = e -> e * 2;
        Function<Integer, Integer> square = e -> e * e;
        //先算name再算square
        int value = name.andThen(square).apply(3);
        System.out.println("andThen value=" + value);
        //先算square再算name
        int value2 = name.compose(square).apply(3);
        System.out.println("compose value2=" + value2);
        //返回一个执行了apply()方法之后只会返回输入参数的函数对象
        Object identity = Function.identity().apply(11);
        System.out.println(identity);
    }
}
